package com.xiyu.service.controller.admin.health;
import com.xiyu.service.vo.health.medicineRegister.MedicineRegisterTemporaryCreateInput;
import com.xiyu.service.vo.health.medicineRegister.MedicineRegisterPlanCreateInput;
import com.xiyu.service.vo.health.medicineRegister.MedicineRegisterPageQueryOutput;
import com.xiyu.service.vo.health.medicineRegister.MedicineRegisterPageQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.health.MedicineRegisterService;

@Tag(name = "用药登记")
@RestController
@RequestMapping("/health/medicine-register")
@Validated
public class MedicineRegisterController {

    @Resource
    private MedicineRegisterService medicineRegisterService;

    @GetMapping("/page-query")
    @Operation(summary = "分页查询用药登记")
    @PreAuthorize("@ss.hasPermission('health:medicineRegister:query')")
    public CommonResult<PageResult<MedicineRegisterPageQueryOutput>> pageQuery(@Valid MedicineRegisterPageQueryInput inputVO) {
        return success(medicineRegisterService.pageQuery(inputVO));
    }

    @PostMapping("/plan-create")
    @Operation(summary = "计划用药登记")
    @PreAuthorize("@ss.hasPermission('health:medicineRegister:plan')")
    public CommonResult<Boolean> planCreate(@Valid @RequestBody MedicineRegisterPlanCreateInput inputVO) {
        return success(medicineRegisterService.planCreate(inputVO));
    }

    @PostMapping("/temporary-create")
    @Operation(summary = "临时用药登记")
    @PreAuthorize("@ss.hasPermission('health:medicineRegister:temporary')")
    public CommonResult<Boolean> temporaryCreate(@Valid @RequestBody List<MedicineRegisterTemporaryCreateInput> inputVO) {
        return success(medicineRegisterService.temporaryCreate(inputVO));
    }

}
